<?xml version="1.0"?>
<component name="org.nuxeo.ecm.platform.mail.web.layouts.contrib.override">

  <require>org.nuxeo.ecm.platform.mail.web.layouts.contrib</require>

  <extension point="layouts" target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager">

    <layout name="mail_listing">
      <templates>
        <template mode="any">/layouts/layout_listing_ajax_template.xhtml</template>
      </templates>
      <columns>
        <column>
          <properties mode="any">
            <property name="isListingSelectionBoxWithCurrentDocument">
              true
            </property>
            <property name="useFirstWidgetLabelAsColumnHeader">false</property>
            <property name="columnStyleClass">iconColumn</property>
          </properties>
          <properties mode="csv">
            <property name="isHidden">true</property>
          </properties>
          <properties mode="pdf">
            <property name="isHidden">true</property>
          </properties>
          <widget>listing_ajax_selection_box_with_current_document</widget>
        </column>
        <column>
          <properties mode="any">
            <property name="useFirstWidgetLabelAsColumnHeader">false</property>
            <property name="columnStyleClass">iconColumn</property>
          </properties>
          <widget>listing_icon_type</widget>
        </column>
        <column>
          <properties mode="any">
            <property name="useFirstWidgetLabelAsColumnHeader">false</property>
            <property name="isSortable">false</property>
          </properties>
          <widget>listing_mail_object</widget>
          <widget>listing_mail_sending_date</widget>
          <widget>listing_mail_contact</widget>
          <widget>listing_mail_body</widget>
        </column>
        <column>
          <properties mode="any">
            <property name="useFirstWidgetLabelAsColumnHeader">false</property>
            <property name="isSortable">false</property>
          </properties>
          <widget>listing_mail_attachments</widget>
        </column>
      </columns>

      <widget name="listing_mail_object" type="listing_mail_object">
        <labels>
          <label mode="any">label.mail.sender</label>
        </labels>
        <translated>true</translated>
        <fields>
          <field>data</field>
          <field>data.ref</field>
        </fields>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
      </widget>
      <widget name="listing_mail_sending_date" type="listing_mail_sending_date">
        <labels>
          <label mode="any">label.mail.sendingDate</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <fields>
          <field>data.mail.sending_date</field>
        </fields>
      </widget>
      <widget name="listing_mail_contact" type="listing_mail_contact">
        <labels>
          <label mode="any">label.mail.sender</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <fields>
          <field>data.mail.sender</field>
          <field>data.mail.recipients</field>
          <field>data.mail.cc_recipients</field>
        </fields>
      </widget>
      <widget name="listing_mail_body" type="listing_mail_body">
        <labels>
          <label mode="any">label.mail.text</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <fields>
          <field>data.mail.text</field>
          <field>data.mail.htmlText</field>
          <field>data.dc.title</field>
          <field>data.id</field>
        </fields>
      </widget>
      <widget name="listing_mail_attachments" type="listing_mail_attachments">
        <labels>
          <label mode="any">label.mail.attachments</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <fields>
          <field>data.files.files</field>
          <field>data</field>
        </fields>
      </widget>
    </layout>

    <layout name="mailMessage">
      <templates>
        <template mode="any">/layouts/layout_default_template.xhtml</template>
      </templates>
      <rows>
      	<row>
          <widget>title</widget>
        </row>
        <row>
          <widget>sender</widget>
        </row>
        <row>
          <widget>sending_date</widget>
        </row>
        <row>
          <widget>recipients</widget>
        </row>
        <row>
          <widget>cc_recipients</widget>
        </row>
        <row>
          <widget>text</widget>
        </row>
      </rows>
      <widget name="title" type="text">
        <labels>
          <label mode="any">label.mail.title</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <translated>true</translated>
        <fields>
          <field>dc:title</field>
        </fields>
        <properties widgetMode="edit">
          <property name="required">true</property>
        </properties>
      </widget>
      <widget name="sender" type="text">
        <labels>
          <label mode="any">label.mail.sender</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <fields>
          <field>mail:sender</field>
        </fields>
      </widget>
      <widget name="sending_date" type="datetime">
        <labels>
          <label mode="any">label.mail.sending_date</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <fields>
          <field>mail:sending_date</field>
        </fields>
        <properties widgetMode="view">
          <property name="pattern">#{nxu:basicDateAndTimeFormatter()}</property>
        </properties>
      </widget>
      <widget name="recipients" type="template">
        <labels>
          <label mode="any">label.mail.recipients</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <fields>
          <field>mail:recipients</field>
        </fields>
        <properties mode="any">
          <property name="template">/widgets/join_list_widget_template.xhtml</property>
        </properties>
      </widget>
      <widget name="cc_recipients" type="template">
        <labels>
          <label mode="any">label.mail.cc_recipients</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <fields>
          <field>mail:cc_recipients</field>
        </fields>
        <properties mode="any">
          <property name="template">/widgets/join_list_widget_template.xhtml</property>
        </properties>
      </widget>
      <widget name="text" type="template">
        <labels>
          <label mode="any">label.mail.text</label>
        </labels>
        <widgetModes>
          <mode value="any">view</mode>
        </widgetModes>
        <properties mode="any">
          <property name="template">/widgets/email_text_widget_template.xhtml</property>
        </properties>
        <fields>
          <field>#{document.id}</field>
        </fields>
      </widget>
    </layout>
    
    <layout name="noLabelFiles">
      <templates>
        <template mode="any">/layouts/layout_default_template.xhtml</template>
      </templates>
      <rows>
        <row>
          <widget>files</widget>
        </row>
      </rows>
      <widget name="files" type="list">
        <labels>
          <label mode="any">label.mail.files</label>
        </labels>
        <translated>true</translated>
        <fields>
          <field schema="files">files</field>
        </fields>
        <properties widgetMode="edit">
          <property name="diff">true</property>
        </properties>
        <properties mode="any">
          <property name="hideSubLabels">true</property>
        </properties>
        <subWidgets>
          <widget name="file" type="file">
        <labels>
          <label mode="any"/>
        </labels>
        <translated>true</translated>
            <fields>
              <field>file</field>
              <field>filename</field>
            </fields>
          </widget>
        </subWidgets>
      </widget>
    </layout>
    
    <layout name="mail_folder">
      <templates>
        <template mode="any">/layouts/layout_default_template.xhtml</template>
      </templates>
      <rows>
        <row>
          <widget>title</widget>
        </row>
        <row>
          <widget>email</widget>
        </row>
        <row>
          <widget>password</widget>
        </row>
        <row>
          <widget>protocol_type</widget>
        </row>
        <row>
          <widget>host</widget>
        </row>
        <row>
          <widget>port</widget>
        </row>
        <row>
          <widget>socket_factory_fallback</widget>
        </row>
        <row>
          <widget>socket_factory_port</widget>
        </row>
        <row>
          <widget>starttls_enable</widget>
        </row>
        <row>
          <widget>ssl_protocols</widget>
        </row>
        <row>
          <widget>emails_limit</widget>
        </row>
      </rows>
      <widget name="title" type="text">
        <labels>
          <label mode="any">label.mail.folder.title</label>
        </labels>
        <translated>true</translated>
        <fields>
          <field>dc:title</field>
        </fields>
        <properties widgetMode="edit">
          <property name="required">true</property>
        </properties>
      </widget>
      <widget name="email" type="text">
        <labels>
          <label mode="any">label.mail.folder.email</label>
        </labels>
        <fields>
          <field>prot:email</field>
        </fields>
        <properties widgetMode="edit">
          <property name="styleClass">dataInputText</property>
          <property name="required">true</property>
        </properties>
      </widget>
      <widget name="password" type="secret">
        <labels>
          <label mode="any">label.mail.folder.password</label>
        </labels>
        <fields>
          <field>prot:password</field>
        </fields>
        <properties widgetMode="edit">
          <property name="styleClass">dataInputText</property>
          <property name="required">true</property>
          <property name="redisplay">true</property>
        </properties>
      </widget>
      <widget name="protocol_type" type="template">
        <labels>
          <label mode="any">label.mail.folder.protocol_type</label>
        </labels>
        <fields>
          <field>prot:protocol_type</field>
        </fields>
        <properties widgetMode="edit">
          <property name="required">true</property>
        </properties>
        <properties mode="any">
          <property name="template">
            /widgets/protocol_type_widget_template.xhtml
          </property>
        </properties>
      </widget>
      <widget name="host" type="text">
        <labels>
          <label mode="any">label.mail.folder.host</label>
        </labels>
        <fields>
          <field>prot:host</field>
        </fields>
        <properties widgetMode="edit">
          <property name="styleClass">dataInputText</property>
        </properties>
      </widget>
      <widget name="port" type="text">
        <labels>
          <label mode="any">label.mail.folder.port</label>
        </labels>
        <fields>
          <field>prot:port</field>
        </fields>
        <properties widgetMode="edit">
          <property name="styleClass">dataInputText</property>
        </properties>
      </widget>
      <widget name="socket_factory_fallback" type="template">
        <labels>
          <label mode="any">label.mail.folder.socket_factory_fallback</label>
        </labels>
        <fields>
          <field>prot:socket_factory_fallback</field>
        </fields>
        <properties mode="any">
          <property name="template">
            /widgets/boolean_radio_widget_template.xhtml
          </property>
        </properties>
      </widget>
      <widget name="socket_factory_port" type="text">
        <labels>
          <label mode="any">label.mail.folder.socket_factory_port</label>
        </labels>
        <fields>
          <field>prot:socket_factory_port</field>
        </fields>
        <properties widgetMode="edit">
          <property name="styleClass">dataInputText</property>
        </properties>
      </widget>
      <widget name="starttls_enable" type="template">
        <labels>
          <label mode="any">label.mail.folder.starttls_enable</label>
        </labels>
        <fields>
          <field>prot:starttls_enable</field>
        </fields>
        <properties mode="any">
          <property name="template">
            /widgets/boolean_radio_widget_template.xhtml
          </property>
        </properties>
      </widget>
      <widget name="ssl_protocols" type="template">
        <labels>
          <label mode="any">label.mail.folder.ssl_protocols</label>
        </labels>
        <fields>
          <field>prot:ssl_protocols</field>
        </fields>
        <properties mode="any">
          <property name="template">
            /widgets/emails_ssl_protocols_widget_template.xhtml
          </property>
        </properties>
      </widget>
      <widget name="emails_limit" type="template">
        <labels>
          <label mode="any">label.mail.folder.emails_limit</label>
        </labels>
        <fields>
          <field>prot:emails_limit</field>
        </fields>
        <properties widgetMode="edit">
          <property name="required">true</property>
        </properties>
        <properties mode="any">
          <property name="template">
            /widgets/emails_limit_widget_template.xhtml
          </property>
        </properties>
      </widget>
    </layout>

  </extension>

</component>
